
'use strict'
var game = require('../app/controllers/game')
var wechat = require('../app/controllers/wechat')
var Index = require('../app/controllers/index')
var User = require('../app/controllers/user')
var Movie = require('../app/controllers/movie')
var Comment = require('../app/controllers/comment')
var Category = require('../app/controllers/category')
var Component = require('../app/controllers/component')
var Crawler = require('../app/controllers/crawler')
var koaBody = require('koa-body')
// Index

module.exports = function(router){
    router.get('/', Index.index)

    // User
    router.post('/user/signup', User.signup)
    router.post('/user/update', User.signinRequired,koaBody({multipart: true,formidable:{uploadDir:'./public/upload',keepExtensions:true}}),User.update)
    router.post('/user/signin', User.signin) 
    router.get('/signin', User.showSignin)
    router.get('/signup', User.showSignup)
    router.get('/logout', User.logout)
    router.get('/admin/user/list', User.signinRequired, User.adminRequired, User.list)


    //wx
    router.get('/wx/articles',game.getarticles)
    router.get('/movie/:id',game.find)
    router.get('/jump/:id',game.jump)
    router.get('/wx',wechat.hear)
    router.post('/wx',wechat.hear)


    // Art
    router.get('/admin/article/one/:id', Movie.detail)
    router.get('/admin/article/:id', Movie.detail)
    router.get('/admin/article/new', User.signinRequired, User.adminRequired, Movie.new)
    router.get('/admin/movie/update/:id', User.signinRequired, User.adminRequired, Movie.update)
    router.post('/admin/article', User.signinRequired, User.adminRequired, Movie.save)
    router.get('/admin/article/list', User.signinRequired, User.adminRequired, Movie.list)
    router.delete('/admin/movie/list', User.signinRequired, User.adminRequired, Movie.del)
    router.post('/admin/upload', koaBody({multipart: true,formidable:{uploadDir:'./public/upload',keepExtensions:true}}), Movie.upload)
    router.post('/admin/article/sendAll',User.signinRequired, User.adminRequired, Movie.sendAll)

    // Comment
    router.post('/user/comment', User.signinRequired, Comment.save) 

    // Category
    router.get('/admin/category/new', User.signinRequired, User.adminRequired, Category.new)
    router.post('/admin/category', User.signinRequired, User.adminRequired, Category.save)
    router.get('/admin/category/list', User.signinRequired, User.adminRequired, Category.list)
    router.delete('/admin/category/list', User.signinRequired, User.adminRequired, Category.del)

    // results
    router.get('/results', Index.search)

    //htmldrop
    router.get('/htmldrop',Component.show)
    //draggerManage
    router.get('/admin/dragmanage',Component.page)
    router.post('/admin/dragmanage',Component.save)
    router.post('/admin/dragmanage/detail',Component.detail)
    router.delete('/admin/dragmanage',Component.del)

    //Crawler
    // router.get('/admin/crawler', Crawler.start)
}